<template>
	<view>
		<uni-popup ref="popup" type="bottom">
			<view class="bg-white ">
				<uni-section title="添加沟通记录" type="circle">
					<template v-slot:right>
						<view @click="close">关闭</view>
					</template>
				</uni-section>
				<view class="padding-bottom-lg padding-sm" style="padding-bottom: 120rpx;">
					<uni-forms class="margin-sm" labelWidth="160rpx">
						<uni-forms-item label="联系时间">
							<uni-datetime-picker type="datetime" v-model="datetimesingle" @change="changeLog" />
						</uni-forms-item>
						<uni-forms-item label="状态">
							<uni-data-checkbox style="width: 100%;" mode="button" v-model="status"
								:localdata="statusList"></uni-data-checkbox>
						</uni-forms-item>
						<uni-forms-item label="联系方式">
							<uni-data-checkbox style="width: 100%;" mode="button" v-model="connectType"
								:localdata="connectTypeList"></uni-data-checkbox>
						</uni-forms-item>

						<uni-forms-item label="内容">
							<uni-easyinput type="textarea" v-model="content"></uni-easyinput>
						</uni-forms-item>
					</uni-forms>
					<button @click="submitForm" class="login-btn cu-btn block bg-blue lg round">提交</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		doInsert
	} from '@/api/marketing/communication'
	import {
		formatTime
	} from '@/utils/validate'
	export default {
		data() {
			return {
				datetimesingle: new Date(),
				statusList: [{
					text: '已联系上',
					value: 1
				}, {
					text: '未联系上',
					value: 2,

				}],
				connectTypeList: [{
					text: '微信',
					value: 0
				}, {
					text: '电话',
					value: 1,

				}, {
					text: '面谈',
					value: 2
				}],
				connectType: 1,
				status: 1,
				content: '',
			}
		},
		props: {
			customerId: null,

			customer: {}
		},
		methods: {
			open(data) {
				// uni.hideTabBar();
				this.customerId = data
				this.$refs.popup.open()
			},
			async submitForm() {
				let {
					success
				} = await doInsert({
					izUsable: "1",
					content: this.content,
					customerId: this.customerId,
					status: this.status,
					type: 1,
					connectType: '1',
					createTime: formatTime(this.datetimesingle),
					remindContent: "",
					remindTime: null,
				})
				if (success) {
					this.close()
				}

			},

			close() {
				Object.assign(this.$data, this.$options.data());
				this.$refs.popup.close()
				// uni.showTabBar();
				this.$emit('refresh')
			},
		}
	}
</script>

<style>
</style>